1   /*
2    * ResourceHandlerTest.java
3    * JUnit based test
4    *
5    * Created on December 22, 2004, 5:11 PM
6    */
7   
8   package gov.noaa.eds.xapi.generic.handlers;
9   
10  import junit.framework.*;
11  import java.net.URL;
12  
13  /***
14   *
15   * @author tns
16   */
17  public class ResourceHandlerTest extends TestCase {
18      
19      ResourceHandler handler = null;
20      
21      public ResourceHandlerTest(String testName) {
22          super(testName);
23      }
24  
25      protected void setUp() throws java.lang.Exception {
26          handler = new ResourceHandler();
27      }
28  
29      protected void tearDown() throws java.lang.Exception {
30      }
31  
32      public static junit.framework.Test suite() {
33          junit.framework.TestSuite suite = new junit.framework.TestSuite(ResourceHandlerTest.class);
34          
35          return suite;
36      }
37  
38      /***
39       * Test of getResource method, of class gov.noaa.eds.xapi.generic.handlers.ResourceHandler.
40       */
41      public void testGetResource() {
42          System.out.println("testGetResource");
43          
44          // TODO add your test code below by replacing the default call to fail.
45          handler.setResource("testXmlResource.xml");
46          String res = handler.getResource();
47          assertNotNull("resource should not return null",res);
48          assertEquals("unexpected resource","testXmlResource.xml",res);
49      }
50      
51      public void testUrlConvertsProperty(){
52          handler.setResource("testXmlResource.xml");
53          URL url = this.getClass().getClassLoader().getResource("testXmlResource.xml");
54          URL convertUrl = handler.getUrl();
55          assertNotNull("url string should have a value",convertUrl);
56          assertEquals("url did not get converted property",url,convertUrl);
57      }
58  
59      /***
60       * Test of setResource method, of class gov.noaa.eds.xapi.generic.handlers.ResourceHandler.
61       */
62      public void testSetResource() {
63          System.out.println("testSetResource");
64          
65          // TODO add your test code below by replacing the default call to fail.
66          handler.setResource("testXmlResource.xml");
67      }
68      
69      // TODO add test methods here. The name must begin with 'test'. For example:
70      // public void testHello() {}
71      
72  }